package hc.bre.runner

import org.codehaus.groovy.control.CompilerConfiguration

@groovy.transform.CompileStatic
class RuleRunnerSupportEx extends RuleRunnerSupport{
	
	String rpath;
	final protected String classFullName() {
		rpath.replace('/', '.')
	}

	final protected String classShortName() {
		def dot = rpath.lastIndexOf("/")
		dot >= 0? rpath.substring(dot+1):rpath
	}
	public static CompilerConfiguration configuration(String classpath) {
		// configuration with classpath don't affect the compile,but affect the run when
		// to call other class.
		if (classpath == null || classpath.trim().equals(""))
			classpath = System.getProperty("user.dir") + "/rulerepo";

		Properties myProperties = new Properties(System.getProperties());

		CompilerConfiguration myConfiguration = new CompilerConfiguration(myProperties);

		myConfiguration.setClasspath(classpath);
		myConfiguration.setSourceEncoding("UTF-8");

		return myConfiguration;
	}
}
